package com.tanhua.dubbo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.domain.db.UserInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 持久层接口
 */
public interface UserInfoMapper extends BaseMapper<UserInfo> {
    /**
     *  Rand()函数是对查询后的结果进行随机的打乱 保证我们每次获取的相似用户都是随机的
     */
    @Select("select * from tb_user_info where gender =#{gender} and id in(SELECT user_id FROM tb_soultest_result where type = #{type} and paper_id = #{paperId} and id <> #{resultId}) ORDER BY RAND() LIMIT 10")
    List<UserInfo> getSimilarYou(@Param("type")Long type, @Param("resultId")Long resultId, @Param("paperId")Integer paperId,@Param("gender") String gender);
}
